#!/usr/bin/env python
#coding=utf8
# vim: set fileencoding=utf8 sts=4 sw=4 expandtab :
"""
 Copyright (C) 2008 Xupeng Yun <recordus@gmail.com>
 
 This file is part of videoapi. videoapi is a python lib/client for video sites such as www.tudou.com.

 Videoapi is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 
 Videoapi is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

 $Id:$
"""

import unittest
import sys
import os

sys.path.append(os.curdir)
sys.path.append(os.pardir)
sys.path.append(os.path.join(os.curdir, 'tests'))

tests = os.listdir(os.curdir)
tests = [n[:-3] for n in tests if n.startswith('test') and n.endswith('.py')]

teststests = os.path.join(os.curdir, 'tests')
if os.path.isdir(teststests):
    teststests = os.listdir(teststests)
    teststests = [n[:-3] for n in teststests if n.startswith('test') \
       and n.endswith('.py')]
    modules_to_test = tests + teststests
else:
    modules_to_test = tests

def suite():
    alltests = unittest.TestSuite()
    for module in map(__import__, modules_to_test):
        alltests.addTest(unittest.findTestCases(module))
    return alltests

if __name__ == '__main__':
    unittest.main(defaultTest='suite')
